package com.system.permission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.system.permission.dao.PermissionRepository;
import com.system.permission.entity.Permission;

@Service
@Transactional
public class PermissionService implements IPermissionService {
	@Autowired	
	private PermissionRepository permissionRepository;
	
	public void saveOrUpdate(Permission permission) {
		permissionRepository.save(permission);
	}
	public void delete(Permission employee) {
		permissionRepository.delete(employee);
	}
	public void delete(List<Long> ids) {
		List<Permission> employee =  (List<Permission>) permissionRepository.findAll(ids);
		if(employee!=null) {
			permissionRepository.delete(employee);
		}
	}
	@Transactional(readOnly = true)
	public Permission findOne(Long permissionId) {
		return permissionRepository.findOne(permissionId);
	}
	@Transactional(readOnly = true)
	public List<Permission> findAll(){
		return (List<Permission>) permissionRepository.findAll();
	}
	//动态条件查询
	@Transactional(readOnly = true)
	public Page<Permission> findAll(Specification<Permission> spec, Pageable pageable){
		return permissionRepository.findAll(spec, pageable);
	}
	@Override
	public List<Permission> findIdsAll(List<Long> ids) {
		return (List<Permission>) permissionRepository.findAll(ids);
	}

	
}
